package com.jyw.business.de.service.impl;

import java.util.List;

import com.alibaba.fastjson2.JSONObject;
import com.jyw.common.utils.DateUtils;
import com.jyw.common.utils.SecurityUtils;
import org.springframework.stereotype.Service;
import com.jyw.business.de.mapper.DeTaskProcessMapper;
import com.jyw.business.de.domain.DeTaskProcess;
import com.jyw.business.de.service.IDeTaskProcessService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.util.ObjectUtils;

import javax.annotation.Resource;

/**
 * 需求-需求任务处理流程Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-02-19
 */
@Service
public class DeTaskProcessServiceImpl extends ServiceImpl<DeTaskProcessMapper,DeTaskProcess> implements IDeTaskProcessService
{
    @Resource
    private DeTaskProcessMapper deTaskProcessMapper;

    /**
     * 查询需求-需求任务处理流程
     * 
     * @param id 需求-需求任务处理流程主键
     * @return 需求-需求任务处理流程
     */
    @Override
    public DeTaskProcess selectDeTaskProcessById(Long id)
    {
        return deTaskProcessMapper.selectDeTaskProcessById(id);
    }

    /**
     * 查询需求-需求任务处理流程列表
     * 
     * @param deTaskProcess 需求-需求任务处理流程
     * @return 需求-需求任务处理流程
     */
    @Override
    public List<DeTaskProcess> selectDeTaskProcessList(DeTaskProcess deTaskProcess)
    {
        return deTaskProcessMapper.selectDeTaskProcessList(deTaskProcess);
    }

    /**
     * 新增需求-需求任务处理流程
     * 
     * @param deTaskProcess 需求-需求任务处理流程
     * @return 结果
     */
    @Override
    public int insertDeTaskProcess(DeTaskProcess deTaskProcess)
    {
        deTaskProcess.setCreateTime(DateUtils.getNowDate());
        return deTaskProcessMapper.insertDeTaskProcess(deTaskProcess);
    }

    /**
     * 修改需求-需求任务处理流程
     * 
     * @param deTaskProcess 需求-需求任务处理流程
     * @return 结果
     */
    @Override
    public int updateDeTaskProcess(DeTaskProcess deTaskProcess)
    {
        deTaskProcess.setUpdateTime(DateUtils.getNowDate());
        return deTaskProcessMapper.updateDeTaskProcess(deTaskProcess);
    }

    /**
     * 批量删除需求-需求任务处理流程
     * 
     * @param ids 需要删除的需求-需求任务处理流程主键
     * @return 结果
     */
    @Override
    public int deleteDeTaskProcessByIds(Long[] ids)
    {
        return deTaskProcessMapper.deleteDeTaskProcessByIds(ids);
    }

    /**
     * 删除需求-需求任务处理流程信息
     * 
     * @param id 需求-需求任务处理流程主键
     * @return 结果
     */
    @Override
    public int deleteDeTaskProcessById(Long id)
    {
        return deTaskProcessMapper.deleteDeTaskProcessById(id);
    }

    @Override
    public void saveProcess(Long id, String operState, Object obj) {
        DeTaskProcess process = new DeTaskProcess();
        process.setTaskId(id);
        process.setOperState(operState);
        if(!ObjectUtils.isEmpty(obj)){
            process.setProcessValue(JSONObject.toJSONString(obj));
        }
        process.setCreateUser(SecurityUtils.getUserId());
        process.setCreateTime(DateUtils.getNowDate());
        save(process);
    }
}
